import unittest

from pyramid import testing


class FormsViewTests(unittest.TestCase):
    def setup(self):
        self.config = testing.setUp()

    def tearDown(self):
        testing.tearDown()

    def test_add(self):
        from .views import FormsView

        request = testing.DummyRequest()
        inst = FormsView(request)
        response = inst.index()
        self.assertEqual(len(response), 0)


class TutorialFunctionTests(unittest.TestCase):
    def setUp(self):
        from forms_model import main
        app = main({})
        from webtest import TestApp

        self.testapp = TestApp(app)

    def test_index(self):
        res = self.testapp.get('/', status=200)
        self.assertIn(b'<form method="POST"', res.body)

